<%@ page language="java" import="java.util.*,java.sql.Connection,
 java.sql.PreparedStatement,
 java.sql.ResultSet,
 java.sql.SQLException,
java.util.ArrayList,
java.util.List,java.sql.DriverManager" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'KeMu.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    This is my JSP page. <br>
    <%
        Class.forName("com.mysql.jdbc.Driver");
        Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/ketang?useSSL=false","root","root");
		PreparedStatement st = null;
		ResultSet rs = null;
		List s = new ArrayList();
		String sql = "select * from subject";
		try {
			st = con.prepareStatement(sql);
			rs = st.executeQuery();
			while (rs.next()) {
				out.print(rs.getInt("id")+"\t");
				out.print(rs.getString("subjectname")+"\t");
				out.print(rs.getInt("classhour")+"\t");
				out.print(rs.getInt("gradeid"));
				%>
				<br/>
				<% 
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			rs.close();
			st.close();
			con.close();
		}
     %>
  </body>
</html>
